/*************************************************************************
	> File Name: oj-143_abcd.c
	> Author: Wang Bo
	> Mail: 1276106221@qq.com
	> Created Time: 2020年10月27日 星期二 14时07分41秒
 ************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#define MAX_LEN 100
int ans[147] = {
    1104, 1116, 1125, 1136, 1149, 1164, 1181,
    1304, 1316, 1325, 1336, 1349, 1364, 1381,
    1704, 1716, 1725, 1736, 1749, 1764, 1781,
    1904, 1916, 1925, 1936, 1949, 1964, 1981,
    2304, 2316, 2325, 2336, 2349, 2364, 2381,
    2904, 2916, 2925, 2936, 2949, 2964, 2981,
    3104, 3116, 3125, 3136, 3149, 3164, 3181,
    3704, 3716, 3725, 3736, 3749, 3764, 3781,
    4104, 4116, 4125, 4136, 4149, 4164, 4181,
    4304, 4316, 4325, 4336, 4349, 4364, 4381,
    4704, 4716, 4725, 4736, 4749, 4764, 4781,
    5304, 5316, 5325, 5336, 5349, 5364, 5381, 
    5904, 5916, 5925, 5936, 5949, 5964, 5981, 
    6104, 6116, 6125, 6136, 6149, 6164, 6181, 
    6704, 6716, 6725, 6736, 6749, 6764, 6781, 
    7104, 7116, 7125, 7136, 7149, 7164, 7181, 
    7304, 7316, 7325, 7336, 7349, 7364, 7381, 
    7904, 7916, 7925, 7936, 7949, 7964, 7981, 
    8304, 8316, 8325, 8336, 8349, 8364, 8381, 
    8904, 8916, 8925, 8936, 8949, 8964, 8981, 
    9704, 9716, 9725, 9736, 9749, 9764, 9781, 
};

int main() {
    int a, b, cnt = 0, ret[100] = {0};
    scanf("%d%d", &a, &b);
    for (int i = 0; i < 147; ++i) {
        if (ans[i] >= a && ans[i] <= b && ans[i] % 6 == 0) ret[cnt++] = ans[i];
    }
    for (int i = 0 ; i < cnt; ++i) {
        i && printf(" ");
        printf("%d", ret[i]);
    }
    printf("\n%d", cnt);
    return 0;
}
